package com.sy.controller;

import com.sy.entity.Video;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class VideoController extends BaseController {
    @RequestMapping(value = "videos", method = RequestMethod.GET)
    public List<Video> getAllVideos() {
        return videoService.getAllVideos();
    }

    @RequestMapping(value = "videos", method = RequestMethod.GET, params = {"type=hottest"})
    public List<Video> getHottestVideos() {
        return videoService.getHottestVideos();
    }

    @RequestMapping(value = "videos/{id}", method = RequestMethod.PUT)
    public void incrPlayVolume(@PathVariable("id") Integer id) {
        videoService.incrPlayVolume(id);
    }

    @RequestMapping(value = "videos/{id}", method = RequestMethod.GET)
    public Video getVideoById(@PathVariable("id") Integer id) {
        return videoService.getVideoById(id);
    }
}
